home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Pentominoes 1.4.1 / source / Pentominoes ƒ / Pent code / pent graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  3.4 KB  |  154 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        pent graphics.c
  4.  
  5. Purpose:    This module handles drawing the playing board in a game.
  6.  
  7.  
  8. Pentominoes - a 2-D geometry board game
  9. Copyright (C) 1993 Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "pent graphics.h"
  29. #include "pent.h"
  30. #include "msg graphics.h"
  31.  
  32. void DrawBoardColor(void)
  33. {
  34.     RGBColor    oldForeColor, oldBackColor;
  35.     GrafPtr        curPort;
  36.     Rect        boardRect;
  37.     int            i,j;
  38.     
  39.     GetForeColor(&oldForeColor);
  40.     GetBackColor(&oldBackColor);
  41.     
  42.     GetPort(&curPort);
  43.     
  44.     EraseRect(&(curPort->portRect));
  45.  
  46.     SetRect(&boardRect,5,gWindowHeight-(gNumRows*25)-5,gWindowWidth-4,gWindowHeight-4);
  47.     FrameRect(&boardRect);
  48.     
  49.     for (i=1; i<gNumCols; i++)
  50.     {
  51.         MoveTo(boardRect.left+i*25,boardRect.top);
  52.         Line(0,gNumRows*25-1);
  53.     }
  54.     
  55.     for (i=1; i<gNumRows; i++)
  56.     {
  57.         MoveTo(boardRect.left,boardRect.top+i*25);
  58.         Line(gNumCols*25-1,0);
  59.     }
  60.     
  61.     for (i=0; i<6; i++)
  62.     {
  63.         boardRect.top=10;
  64.         boardRect.bottom=42;
  65.         boardRect.left=(gWindowWidth/2)-((3-i)*34)+1;
  66.         boardRect.right=boardRect.left+32;
  67.         if (!PieceUsed[i])
  68.             PlotCIcon(&boardRect, gColorIcons[i]);
  69.         
  70.         boardRect.top+=40;
  71.         boardRect.bottom+=40;
  72.         if (!PieceUsed[i+6])
  73.             PlotCIcon(&boardRect, gColorIcons[i+6]);
  74.     }
  75.  
  76.     boardRect.bottom=gWindowHeight+20-(gNumRows*25);
  77.     boardRect.top=boardRect.bottom-24;
  78.     
  79.     for (i=0; i<gNumRows; i++)
  80.     {
  81.         boardRect.left=6;
  82.         boardRect.right=30;
  83.         for (j=0; j<gNumCols; j++)
  84.         {
  85.             FillCRect(&boardRect,gPlainColors[Board[i][j]+2]);
  86.             boardRect.left+=25;
  87.             boardRect.right+=25;
  88.         }
  89.         boardRect.top+=25;
  90.         boardRect.bottom+=25;
  91.     }
  92.     
  93.     RGBForeColor(&oldForeColor);
  94.     RGBBackColor(&oldBackColor);
  95. }
  96.  
  97. void DrawBoardBW(void)
  98. {
  99.     int            i,j;
  100.     Rect        boardRect;
  101.     GrafPtr        curPort;
  102.     
  103.     GetPort(&curPort);
  104.     
  105.     EraseRect(&(curPort->portRect));
  106.  
  107.     SetRect(&boardRect,5,gWindowHeight-(gNumRows*25)-5,gWindowWidth-4,gWindowHeight-4);
  108.     FrameRect(&boardRect);
  109.     
  110.     for (i=1; i<gNumCols; i++)
  111.     {
  112.         MoveTo(boardRect.left+i*25,boardRect.top);
  113.         Line(0,gNumRows*25-1);
  114.     }
  115.     
  116.     for (i=1; i<gNumRows; i++)
  117.     {
  118.         MoveTo(boardRect.left,boardRect.top+i*25);
  119.         Line(gNumCols*25-1,0);
  120.     }
  121.     
  122.     for (i=0; i<6; i++)
  123.     {
  124.         boardRect.top=10;
  125.         boardRect.bottom=42;
  126.         boardRect.left=(gWindowWidth/2)-((3-i)*34)+1;
  127.         boardRect.right=boardRect.left+32;
  128.         if (!PieceUsed[i])
  129.             PlotIcon(&boardRect, gBWIcons[i]);
  130.         
  131.         boardRect.top+=40;
  132.         boardRect.bottom+=40;
  133.         if (!PieceUsed[i+6])
  134.             PlotIcon(&boardRect, gBWIcons[i+6]);
  135.     }
  136.  
  137.     boardRect.bottom=gWindowHeight+20-(gNumRows*25);
  138.     boardRect.top=boardRect.bottom-24;
  139.     
  140.     for (i=0; i<gNumRows; i++)
  141.     {
  142.         boardRect.left=6;
  143.         boardRect.right=30;
  144.         for (j=0; j<gNumCols; j++)
  145.         {
  146.             FillRect(&boardRect,*gBWPatterns[Board[i][j]+2]);
  147.             boardRect.left+=25;
  148.             boardRect.right+=25;
  149.         }
  150.         boardRect.top+=25;
  151.         boardRect.bottom+=25;
  152.     }
  153. }
  154.